package com.example.javagd.util;

import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * @program: java-general-development
 * @description:
 * @author: hzy
 * @create: 2021-04-02 13:25
 **/
@Component
@Data
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    public Result<T> SuccessMsg(String msg){
        code = 0;
        data = null;
        this.msg = msg;
        return this;
    }

    public Result<T> ErrorMsg(String msg){
        code = -1;
        data = null;
        this.msg = msg;
        return this;
    }


    public Result<T> Success(T object){
        code = 0;
        data = object;
        return this;
    }

    public Result<T> Error(T object){
        code = -1;
        data = object;
        return this;
    }

    public Result<T> Success(T object, String msg){
        code = 0;
        data = object;
        this.msg = msg;
        return this;
    }

    public Result<T> Error(T object, String msg){
        code = -1;
        data = object;
        this.msg = msg;
        return this;
    }
}
